package monster.com.cvh.activity;

import android.content.Intent;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;
import monster.com.cvh.R;
import monster.com.cvh.activity.base.PermissionActivity;
import monster.com.cvh.constant.Constans;
import monster.com.cvh.fragment.DownResumeFragment;
import monster.com.cvh.fragment.UnLockResumeFragment;
import monster.com.cvh.util.MyConstant;

/**
 * @author: 13580
 * @data: 2018/4/12
 * @function:下载简历Activity
 */
public class DownAndSendResumeActivity extends PermissionActivity {
    private static final String TAG = "DownAndSendResumeActivi";
    @BindView(R.id.tv_include_top_bar_title)
    TextView mTvTitle;
    @BindView(R.id.tv_include_top_bar_save)
    TextView mTvAction;
    private DownResumeFragment mDownResumeFragment;
    private int mCode = -1;//Fragment的code
    private boolean mIsDownResume = false;//是否为下载简历Fragment界面
    private int mTemplateId;
    private String mFileName;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_down_and_resume;
    }

    @Override
    protected void initEvent() {
        changeStatusBarColorDark(DownAndSendResumeActivity.this, R.color.white);
        mTvAction.setVisibility(View.GONE);
        if (mCode == Constans.DOWN_LOAD_RESUME) {
            mIsDownResume = true;
            mTvTitle.setText(R.string.activity_down_and_send_resume_title);
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            mDownResumeFragment = DownResumeFragment.newInstance(mTemplateId, mFileName);
            transaction.replace(R.id.cfl_content, mDownResumeFragment);
            transaction.commit();
        } else if (mCode == Constans.UNLOCK_RESUME) {
            mTvTitle.setText(R.string.activity_down_and_send_reseme_unlock_title);
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.cfl_content, UnLockResumeFragment.newInstance());
            transaction.commit();
        }


    }

    @Override
    protected void initData() {
        Intent intent = getIntent();
        if (intent != null) {
            mCode = intent.getIntExtra(Constans.DOWN_RESUME, -1);
            mTemplateId = intent.getIntExtra(MyConstant.TEMPLATE_ID, 1);
            mFileName = intent.getStringExtra(MyConstant.FILE_NAME);
            if (mFileName==null||mFileName.isEmpty()){
                mFileName=getString(R.string.activity_down_and_send_resume_default_file_name);
            }
        }
    }


    @OnClick(R.id.iv_include_top_bar_back)
    public void onViewClicked() {
        finish();
    }

}
